
        (async function () {

          // let applink = {
          //   info: {}
          // }
          // let appDoloadLink = $utils.isAndroid ? applink.info.android : applink.info.ios
          // $('#appDoloadLink').attr('href', appDoloadLink)

          const Dom = {
              card_tabbar: $('#card-tabbar'),
              card_tabbar_item: $('#card-tabbar .tabbar-item'),
              cards: $('.cards'),
              mobile: $('#mobile'),
              password: $('#password'),
              surePassword: $('#surePassword'),
              inviteCode: $('#invite_code'),
              tradPassword: $('#trad_password'),
              code: $('#code'),
              verifyCode: $('#verifyCode'),
              verifyCodePic: $('#verifyCodePic'),
              submitButton: $('#submitButton'),
              phoneCodeBtn: $('#phoneCodeBtn')
          }


          let mobile = ''
          let verifyCode = ''
          let checkVerifyCode = ''
          let code = ''
          let password = ''
          let surePassword = ''
          let trad_password = ""
          let trad_password_sure = ""
          let invite_code = $utils.getLocalStorage('code') || ''
          let agreenmentChecked = false
          let wx = ''

          if (invite_code) {
              Dom.inviteCode.val(invite_code)
          }
          EventHandler()

          function EventHandler() {

            // let cavnas = document.getElementById('canvas')
            //   checkVerifyCode = $utils.drawPic(Dom.verifyCodePic, cavnas)

            //   Dom.verifyCodePic.click(function () {
            //       checkVerifyCode = $utils.drawPic(Dom.verifyCodePic, cavnas)
            //   })

              // 获取手机验证码
              Dom.phoneCodeBtn.click(async function () {

                  if (!mobile) {
                      $utils.showMsg('请先输入手机号')
                      return
                  }

                  if(isSend) {
                    return;
                  }

                  $http.get('/publics/api.sms/sendCode', { mobile, type: 'register' })
                    .then(res => {
                      if(res.data.code == 0) {
                        $utils.showMsg(res.data.msg)
                        isSend = false;
                        return
                      }

                        $utils.sendSms($('#phoneCodeBtn'))
                        $utils.showMsg(res.data.msg)
                    })
              })

              // 修改密码提交
              Dom.submitButton.click(async function () {

                let nick_name = $('#nick_name').val()
                let pid = $('#pid').val()

                  if (!mobile) {
                      $utils.showMsg('请输入手机号')
                      return
                  }
                  // if (!verifyCode) {
                  //     $utils.showMsg('请输入验证码')
                  //     return
                  // }
                  // if (verifyCode !== checkVerifyCode) {
                  //     $utils.showMsg('验证码不正确')
                  //     return
                  // }
                  if (!code) {
                      $utils.showMsg('请输入手机验证码')
                      return
                  }
                  if (!password) {
                      $utils.showMsg('请输入登录密码')
                      return
                  }
                  // if (!surePassword) {
                  //     $utils.showMsg('请确认新密码')
                  //     return
                  // }

                  // if (password !== surePassword) {
                  //     $utils.showMsg('登录密码和确认登录密码不一致')
                  //     return
                  // }

                  if (!agreenmentChecked) {
                      $utils.showMsg('请同意 《会员手册》 电子协议')
                      return
                  }

                  let params = { mobile, password, code, nick_name, pid }
                  $http.post('/member/api.passport/register', params)
                    .then(res => {
                      if(res.data.code == 0) {
                        $utils.showMsg(res.data.msg)
                        isSend = false;
                        return
                      }
                      $utils.showMsg(res.data.msg, function () {
                          if (res.data.code == 1) {
                              location.href = './login.html'
                          }
                      })
                    })
     

              })

              Dom.mobile.on('input', function () {
                  mobile = this.value
              })

              Dom.password.on('input', function () {
                  password = this.value
              })

              Dom.verifyCode.on('input', function () {
                  verifyCode = this.value
              })
              
              $('#wx').on('input', function () {
                 wx = this.value
              })

              Dom.code.on('input', function () {
                  code = this.value
              })
              Dom.tradPassword.on('input', function () {
                  trad_password = this.value
              })
              Dom.inviteCode.on('input', function () {
                  invite_code = this.value
              })

              Dom.mobile.on('input', function () {
                  mobile = this.value
              })

              Dom.password.on('input', function () {
                  password = this.value
              })

              $('#surePassword').on('input', function () {
                  surePassword = this.value
              })

              Dom.verifyCode.on('input', function () {
                  verifyCode = this.value
              })

              $('#trad_password').on('input', function () {
                  trad_password = this.value
              })

              $('#trad_password_sure').on('input', function () {
                  trad_password_sure = this.value
              })

              $('#agreenment').on('change', function () {
                  agreenmentChecked = this.checked
              })
          }


      })()